package com.sky.mapper;

import com.sky.entity.OrderDetail;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderDetailMapper {

    /**
     * 根据ID查询订单详情
     *
     * @param id 订单详情ID
     * @return 订单详情实体
     */
    @Select("SELECT * FROM order_detail WHERE id = #{id}")
    OrderDetail getById(Long id);

    /**
     * 插入订单详情
     *
     * @param orderDetail 订单详情实体
     */
    void insert(OrderDetail orderDetail);

    /**
     * 批量插入订单详情
     *
     * @param orderDetails 订单详情实体列表
     */
    void insertBatch(List<OrderDetail> orderDetails);

    /**
     * 根据订单ID查询订单详情
     *
     * @param id 订单ID
     * @return 订单详情列表
     */
    @Select("SELECT * FROM order_detail WHERE order_id = #{id}")
    List<OrderDetail> listByOrderId(Long id);
}
